using Dapper;
using System.Data;

namespace AdminApiTemplate.Services.Sys
{
    public class OperationLogService
    {
        private readonly IDbConnection _dbConnection;

        public OperationLogService(
            IDbConnection dbConnection)
        {
            _dbConnection = dbConnection;
        }

        /// <summary>
        /// 插入操作日志
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int InsertOperationLog(OperationLogRequestModel model)
        {
            string sql = @"insert into operationlog(AUID,OperationType,P1,P2,P3,P4,P5,CreateTime)
                                     VALUES(@AUID,@OperationType,@P1,@P2,@P3,@P4,@P5,now());";
            DynamicParameters dp = new DynamicParameters();
            dp.Add("@AUID", model.AUID);
            dp.Add("@OperationType", model.OperationType);
            dp.Add("@P1", model.P1);
            dp.Add("@P2", model.P2);
            dp.Add("@P3", model.P3);
            dp.Add("@P4", model.P4);
            dp.Add("@P5", model.P5);
            return _dbConnection.Execute(sql, dp);
        }
    }
}
